All Questions
Tagged with scalaunit-testing
14 questions
7votes
1answer
179views
Readable unit test - lists of complex objects
Goal: Writing more readable tests. I have a couple of functions, which basically merge and converts two lists of Datasets together, written using Scala and Spark. Each of these Datasets has a lot of ...
5votes
1answer
264views
Scala Docx generator from CSV input, using the docx4j library and Scala Swing
I am working on an application which takes as input a CSV file containing a list of attributes and a .docx template containing variable names equal to the columns ...
5votes
1answer
249views
Bowling game Kata in Scala - pattern match
This is a functional approach to problem described by standard Bowling Game Kata - to implement the rules of calculating a score in a bowling game. The inspiration was the implementation by Uncle Bob: ...
2votes
1answer
1kviews
Hamming distance in Scala
Problem Write a program that can calculate the Hamming difference between two DNA strands. GAGCCTACTAACGGGAT CATCGTAATGACGGCCT ^ ^ ^ ^ ^ ^^ Code ...
2votes
1answer
990views
Anagram in Scala
Code ...
5votes
3answers
189views
Nucleotide count in Scala
This is my second day in learning Scala and I still need to develop a taste of functional programming, I often find myself doing imperative coding. Below is the result of my TDD practice. Code ...
6votes
2answers
618views
String Calculator Kata in Scala
This is my solution of string calulator kata in scala(i'm new of tdd). I'd like a general review of this. String Calculator Create a simple String calculator with a method int Add(string ...
4votes
1answer
302views
White box input stream for creating test scenarios
I need to test a specialized input stream class that takes input from a TCP/IP network connection. I particularly need to ensure that the blocking and availability behavior is correct. To help me ...
5votes
1answer
432views
Safe cracker string with all combinations
Imagine a safe with a 4-digit code, and accepting a continuous stream of code entries, such that when the 4 digits are seen in the right sequence, the safe opens. Generate a short string that contains ...
4votes
1answer
323views
Find minimum number of coins (count and list of coins too)
For a given set of denominations, you are asked to find the minimum number of coins with which a given amount of money can be paid. Assume that you can use as many coins of a particular denomination ...
11votes
2answers
5kviews
Sqrt (square root) function
As an exercise in learning Scala, I implemented a square root function like this: ...
5votes
2answers
3kviews
Reading and parsing CSV files
This is my first real attempt at a Scala program. I come from a predominantly Java background, so I'd like to know if the program sticks to Scala conventions well. Is it well readable or should it ...
3votes
0answers
924views
Testing Scala code which depends on objects
I am writing a small oauth2 library for Play! 2.1 scala. As I am still learning I got stuck trying to TDD and ended up writing the code first, then refactoring for testability. By testability I mean ...
16votes
1answer
591views
TDD and function injection
I'm trying to come up with a scalable way of TDD'ing my Scala code, in particular managing dependencies. In this example, I've TDD'd part of the classic river crossing problem where we have people on ...